import Coordinates from "../Coordinates";
import IconFramesMgr from "../IconFramesMgr";
import LevelLogic from "../logic/LevelLogic";
import PlayerDataMgr from "../PlayerDataMgr";
import ResManager from "../ResManager";
import Util from "../../../StartAb/Util";

const { ccclass, property } = cc._decorator;

@ccclass
export default class SunshineLackDialog extends cc.Component {

    start() {

    }

    play(e: cc.Event.EventTouch) {
        //TO Test if
        let btn: cc.Button = e.target.getComponent(cc.Button);
        btn && (btn.enabled == false)
        let nextLv = LevelLogic.getCurrentPlayLevel();
        if (nextLv == -1) {
            IconFramesMgr.getInstance().loadIcons(() => {
                Util.changeScene("levelList");
            })
        } else {
            Coordinates.loadLvCoordinate(nextLv, () => {
                ResManager.currentLevelIndex = nextLv
                PlayerDataMgr.getInstance().setLastLevelIndex(nextLv)
                Util.changeScene("game");
            })
        }
    }

    close() {
        this.node.destroy()
    }
}
